package com.itheima;

import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/servletSet")
public class ServletSet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Map<String, String[]> parameterMap = request.getParameterMap();
        User u =new User();
        try {
            BeanUtils.populate(u,parameterMap);
        } catch (Exception e) {
        }
        String id = request.getParameter("id");
        System.out.println(id);
        u.setId(id);
        UserDao u1=new UserDao();
        System.out.println(u);
        u1.setList(u);
        request.getRequestDispatcher("/servletLook").forward(request,response);
    }
}